﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Net.Fan.SmallPig.DataAccess;
using Net.Fan.SmallPig.BusinessRules;
using Net.Fan.SmallPig.Common.DBMeta;
using System.Data;

public partial class Job_DoOperate : System.Web.UI.Page
{
    long jobId;
    long ActiviteId;

    protected void Page_Load(object sender, EventArgs e)
    {
        string js = Request.Params["J"];
        long.TryParse(js, out jobId);
        //HiddenFieldJobID.Value = js;

        string ac = Request.Params["A"];
        long.TryParse(ac, out ActiviteId);
        if (IsPostBack == false)
        {
            bool havePermission = JobBiz.HaveActionPermission(ActiviteId, this.User.Identity.Name);
            if (havePermission)
            {
                DataRow job = JobDA.GetJob(jobId);
                //LabelJobId.Text = js;
                HyperLinkJobId.Text = js;
                HyperLinkJobId.NavigateUrl = "Job.aspx?J=" + js;
                LabelSummary.Text = job[JobMeta.SummaryField] as string;

                string op = WorkflowDA.GetOperate(ActiviteId);
                Button1.Text = op;
            }
            else
            {
                Response.Write("你没有此操作的权限，如果对此有疑问请与管理员联系。");
                Response.End();
            }
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        JobBiz.DoOperate(jobId, ActiviteId, TextBox1.Text, this.User.Identity.Name);
        Response.Redirect("Jobs.aspx?T=MY");
        //Response.Redirect(string.Format("Jobs.aspx?J={0}", jobId));
    }
}
